home *** CD-ROM | disk | FTP | other *** search
- -- card: 45653 from stack: in.3r
- -- bmap block id: 0
- -- flags: 0000
- -- background id: 2202
- -- name: convertDate
-
-
- -- part contents for background part 10
- ----- text -----
- 15
-
- -- part contents for background part 19
- ----- text -----
- Functions
-
- -- part contents for background part 3
- ----- text -----
- convertDate
-
- -- part contents for background part 2
- ----- text -----
- --This is a general function to convert date formats from
- --standard HyperCard format: m/d/yy (m or d can have 1 or 2 digits)
- --to TPS/IBM format: yymmdd
-
- --Returns "format error" if format is not correct
-
- --examples:
- --convertdate(the date) gives 880528 (if today's date is 5/28/88)
- --convertdate("12/1/88") gives 881201
- --convertdate(5/3/88) doesn't work because HyperCard evaluates the
- --expression (2 divisions) before passing the argument to the function.
- --however, put the date into Y followed by convertdate(Y) does work
- --(apparently HC uses a special hidden marker for dates?)
- --From:
- --Peter Sylvan
- --65 Valley Road
- --Milton, MA 02186
- --
- --I would like to thank Peter for sending in this contribution to the Developer Stack. [Steve].
-
- function convertdate x -- input format m/d/yy, output format yymmdd
- convert x to date -- adjust date to real calendar if necessary
- if char 3 of x is "/" then -- two digits in the input m
- put char 1 to 2 of x into mm
- put empty into char 1 to 3 of x
- else if char 2 of x is "/" then -- only one digit in the input m
- put "0" & char 1 of x into mm
- put empty into char 1 to 2 of x
- else
- return "format error" -- perhaps should return empty?
- end if
- if char 3 of x is "/" then
- put char 1 to 2 of x into dd
- put empty into char 1 to 3 of x
- else if char 2 of x is "/" then
- put "0" & char 1 of x into dd
- put empty into char 1 to 2 of x
- else
- return "format error"
- end if
- return x & mm & dd
- end cdate
-
-